# Copyright (c) 2010 Peter Polacik <polacik.p@gmail.com>
# Licensed under MIT License

VERSION = 0.1
OUT_FILE = libaic.so.${VERSION}
IDIR = /usr/lib
INC_DIR = include

CC = gcc
LINKER = gcc
CFLAGS = -fPIC -c -Wall -I ${INC_DIR} -o
LDFLAGS = -shared -Wl,-soname,libaic.so.1 -o ${OUT_FILE}
TESTFLAGS = -L . -Wl,-rpath,. -laic -o

OBJ = lib/libaic.o lib/portscan.o lib/math.o

.PHONY: all

all: ${OBJ} ${OUT_FILE} libaic.so libaic.so.1

${OUT_FILE}: ${OBJ}
	${LINKER} ${LDFLAGS} ${OBJ}

libaic.so: ${OUT_FILE}
	ln -s ${OUT_FILE} libaic.so

libaic.so.1: ${OUT_FILE}
	ln -s ${OUT_FILE} libaic.so.1

lib/libaic.o:
	${CC} ${CFLAGS} lib/libaic.o src/libaic.c

lib/portscan.o:
	${CC} ${CFLAGS} lib/portscan.o src/portscan.c

lib/math.o:
	${CC} ${CFLAGS} lib/math.o src/math.c

test: test.c
	${CC} ${TESTFLAGS} test test.c

clean:
	rm -f ${OBJ} ${OUT_FILE} libaic.so libaic.so.1 test

install:
	scripts/install.sh ${OUT_FILE} ${IDIR}
